package com.example.qcrmdemo.service.impl;

import com.example.qcrmdemo.dao.SalesPlanMapper;
import com.example.qcrmdemo.dao.ServeMapper;
import com.example.qcrmdemo.entity.SalesPlan;
import com.example.qcrmdemo.entity.Serve;
import com.example.qcrmdemo.service.ServeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServeServiceImpl implements ServeService {

    @Autowired
    private ServeMapper serveMapper;

    @Override
    public PageInfo<Serve> findByKeyword(int pageNum, int pageSize, String keyword) {
        PageHelper.startPage(pageNum,pageSize);
        List<Serve> serves= serveMapper.selectByKeyword(keyword);
        PageInfo<Serve> pageInfo=new PageInfo<>(serves);
        return pageInfo;
    }

    @Override
    public Serve findById(int id) {
        return serveMapper.selectById(id);
    }

    @Override
    public boolean append(Serve serve) {
        return serveMapper.insert(serve)>0;
    }

    @Override
    public boolean modify(Serve serve) {
        return serveMapper.updateById(serve)>0;
    }

    @Override
    public boolean remove(int id) {
        return serveMapper.deleteById(id)>0;
    }

    @Override
    public PageInfo<Serve> selectAll() {
        List<Serve> serves= serveMapper.selectAll();
        PageInfo<Serve> pageInfo=new PageInfo<>(serves);
        return pageInfo;
    }

    @Override
    public PageInfo<Serve> selectWeiFenPei() {
        List<Serve> serves= serveMapper.selectWeiFenPei();
        PageInfo<Serve> pageInfo=new PageInfo<>(serves);
        return pageInfo;
    }

    @Override
    public PageInfo<Serve> selectWeiChuLi() {
        List<Serve> serves= serveMapper.selectWeiChuLi();
        PageInfo<Serve> pageInfo=new PageInfo<>(serves);
        return pageInfo;
    }

    @Override
    public PageInfo<Serve> selectWeiFanKui() {
        List<Serve> serves= serveMapper.selectWeiFanKui();
        PageInfo<Serve> pageInfo=new PageInfo<>(serves);
        return pageInfo;
    }

    @Override
    public PageInfo<Serve> selectYiWanCheng() {
        List<Serve> serves= serveMapper.selectYiWanCheng();
        PageInfo<Serve> pageInfo=new PageInfo<>(serves);
        return pageInfo;
    }
}
